<template>
  <van-overlay :show="showCover">
    <button @click="goNow(1)">Cover</button>
    <div class="wrapper">
      <div class="init_content" v-if="showCover">
        <div class="progress" v-if="progress < 100">
          <van-progress
            :percentage="progress > 100 ? 100 : progress"
            stroke-width="16"
            color="rgb(211 180 8)"
            :show-pivot="false"
            @change="progressChange"
          />
        </div>
        <div v-if="progress < 100" class="progress_num">
          Loading...
          <animationNumber
            :progress="progress > 100 ? 100 : progress"
          ></animationNumber
          >
          %
        </div>
        <div v-else>
          <div class="user_action">
            <img
              :src="action"
              v-if="userTime > 0 && reason_to_showDialog !== 3"
              @click="goAction"
            />
            <img
              :src="noAction"
              v-if="userTime <= 0 || reason_to_showDialog === 3"
            />
          </div>
          <div class="user_remain_time">
            <img
              style="margin-left: -15px"
              :src="remainCount"
              v-if="userTime > 0 && reason_to_showDialog !== 3"
            />
            <img
              :src="tomorrow"
              v-if="userTime <= 0 || reason_to_showDialog === 3"
            />
          </div>
          <div
            class="remain_time_num"
            v-if="userTime > 0 && reason_to_showDialog !== 3"
          >
            {{ userTime }}
          </div>
        </div>
      </div>
    </div>
  </van-overlay>

</template>

<script>
import animationNumber from '@/components/animationNumber';
import action from '../img/action.png';
import tomorrow from '../img/tomorrow.png';
import remainCount from '../img/remainCount.png';
import noAction from '../img/noAction.png';
export default {
  name: 'homePageDialog',
  components:{
    animationNumber
  },
  props:{
    userTime:{
      default:0,
      type:Number
    },
    reason_to_showDialog:{
      default:0,
      type:Number
    },
    showCover:{
      default:true,
      type:Boolean
    },


  },
  data() {
    return {
      progress:0,
      tomorrow: tomorrow,
      action:action,
      noAction:noAction,
      remainCount:remainCount,
      progressInterval:null
    }
  },
  mounted() {
    //进度条开始
    this.progressInterval = window.setInterval(() => {
      this.progress += 1;
    }, 100);

  },
  methods: {
    goNow() {
      this.$emit("goNow",1)
    },
    goAction(){
      this.$emit("goAction")

    },
    //进度条变化
    progressChange(event) {
      const progress = event.detail;
      console.log(progress);
    },

  }

};
</script>

<style scoped lang="scss">
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  .init_content {
    background-image: url(../img/actionBg.png);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: right;
    box-sizing: border-box;
    width: 757px;
    height: 450px;
    position: relative;
    font-size: 18px;
    padding: 0 30px;
    .progress {
      position: absolute;
      left: 180px;
      top: 367px;
      width: 400px;
    }
    .progress_num {
      position: absolute;
      bottom: 30px;
      left: 320px;
      color: gold;
      font-size: 20px;
    }
    .user_action {
      position: absolute;
      bottom: 44px;
      left: 283px;
      img {
        width: 188px;
        height: 59px;
      }
    }

    .user_remain_time {
      position: absolute;
      bottom: 18px;
      left: 320px;
      .firstClass {
        position: absolute;
        bottom: 18px;
        left: 308px;
      }
      img {
        width: 110px;
        height: 17px;
      }
    }
    .remain_time_num {
      position: absolute;
      bottom: 15px;
      right: 320px;
      width: 18px;
      height: 29px;
      line-height: 29px;
      color: gold;
      font-size: 26px;
    }
    .title {
      width: 100%;
      height: 100px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .rules {
      width: 100%;
      height: 80px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .action {
      width: 100%;
      height: 50px;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-top: 15px;
      margin-bottom: 15px;
    }
    .remainNum {
      width: 100%;
      height: 30px;
      display: flex;
      justify-content: center;
      align-items: center;

      .num_content {
        width: 320px;
        height: 20px;
        border: 1px solid rgb(109, 107, 107);
        border-radius: 20px;
        text-align: center;
        font-size: 16px;
      }
    }
  }
}


</style>
